# -*- encoding: utf-8 -*-
# @File     :   celery_app.py
# @Time     :   2021/1/9 9:18 上午
# @Author   :   Lv HaoRan
# @Email    :   905097829@qq.com
# @Software :   PyCharm
# @Desc     :
import os

from celery import Celery
from mycelery import conf

project_name = "dj_demo"
celery_app = Celery(project_name)

# 加载Django的环境
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "celeryPros.settings.dev")

# 配置celery实例化参数
celery_app.config_from_object(conf)

# 加载celery任务逻辑
celery_app.autodiscover_tasks([
    "mycelery.email"
])

# 启动Celery的命令
# 强烈建议切换目录到mycelery根目录下启动
# celery worker -A mycelery.celery_app -l info
